<template>
  <div class="flex text-#ffffff">
    <div @click="minimizeHandle"
      class="flex items-center justify-center w-7.3rem header-icon cursor-pointer hover:bg-#e3e3e3 text-#929292">
      <SvgIcon local-icon="minimize" class="h-1.5rem w-1.9rem" />
    </div>
    <div @click="maximizeHandle"
      class="flex items-center justify-center w-7.3rem header-icon cursor-pointer bg hover:bg-#e3e3e3 text-#929292">
      <SvgIcon local-icon="midsize" v-if="isMaximized" class="h-1.9rem" />
      <SvgIcon local-icon="maximize" v-else class="h-1.5rem" />
    </div>
    <div @click="closeHandle"
      class="flex items-center justify-center w-7.3rem header-icon cursor-pointer hover:bg-#e3e3e3 text-#929292">
      <SvgIcon local-icon="close" class="h-1.6rem" />
    </div>
  </div>
</template>
<script lang="ts" setup>
import { useDialog } from 'naive-ui';
import { ref } from 'vue';


const isMaximized = ref(false);

const dialog = useDialog();

/**
 * @description: 关闭窗口
 */
async function closeHandle() {


  if (false) {
    dialog.warning({
      title: '文件已改变',
      content: '是否要保存对该文件的修改',
      positiveText: '保存',
      negativeText: '不保存',
      maskClosable: false,
      onPositiveClick: () => {
        console.log("保存操作")
      },
      onNegativeClick: () => {
        window.electron.closeWindow();
      },
    });
  } else {
    window.electron.closeWindow();
  }
}
/**
 * @description: 最大化窗口
 */
function minimizeHandle() {
  window.electron.minimizeWindow();
}
/**
 * @description: 最小化窗口
 */
function maximizeHandle() {
  window.electron.maximizeWindow();
}

window.electron.onWinSize((_: any, value: boolean) => {
  isMaximized.value = value;
});


</script>
<style scoped>
/* electron 按钮不可拖拽*/
.header-icon {
  -webkit-app-region: no-drag;
}
</style>
